﻿using FreeSql;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;

namespace FreeSqlExtend
{
    public static class FreeSqlInitialization
    {
        private static IFreeSql testDbIFreeSql = null;
        static FreeSqlInitialization()
        {
            testDbIFreeSql = new FreeSql.FreeSqlBuilder().UseNoneCommandParameter(true)
            .UseConnectionString(DataType.MySql, @"Data Source=10.1.1.12;Port=3308;User ID=root;Password=js123456;Initial Catalog=tt;pooling=false;charset=utf8;Min Pool Size=5;Max Pool Size=50;SslMode=None;")
            .UseAutoSyncStructure(true) //自动同步实体结构到数据库，FreeSql不会扫描程序集，只有CRUD时才会生成表。
            .UseSlave(new string[] { })//从库配置多个
            .Build(); //请务必定义成 Singleton 单例模式
        }

        public static IFreeSql Initialization(string dbName)
        {
            switch (dbName)
            {
                case "tt":
                    return testDbIFreeSql;
                default:                    
                    return null;
            }
        }
    }
}